{extend name="base"}
{block name="content"}
<ol class="breadcrumb" style="background-color: #f9f9f9;padding:8px 0;margin-bottom:10px;">
    <li>
        <a href=""><i class="fa fa-cogs"></i>
            栏目管理</a>
    </li>
    <li class="active">
        <a href="">栏目列表</a>
    </li>
</ol>
<ul class="nav nav-tabs" role="tablist">
    <li class="active"><a href="">栏目列表</a></li>
    <li><a href="{:url('store')}">添加栏目</a></li>
</ul>
<form action="" method="post">
    <div class="panel panel-default">
        <div class="panel-body">
            <table class="table table-hover">
                <thead>
                <tr>
                    <th width="80">编号</th>
                    <th>栏目名称</th>
                    <th width="200">操作</th>
                </tr>
                </thead>
                <tbody>
                {foreach name='field' key='key' item='vo'}
                <tr>
                    <td>{$vo['cate_id']}</td>
                    <td>
                        {:str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;',$vo['level'])}
                        {empty name="vo['level']"}
                            <span style="font-weight:bold;">{$vo['cate_name']}</span>
                        {/empty}
                        {notempty name="vo['level']"}
                            <i class="fa fa-circle-o"></i>
                            {$vo['cate_name']}
                        {/notempty}
                    </td>
                    <td>
                        <div class="btn-group">
                            <button data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">操作 <span class="caret"></span></button>
                            <ul class="dropdown-menu dropdown-menu-right">
                                <li><a href="{:url('addSon',['cate_id'=>$vo['cate_id']])}">添加子类</a></li>
                                <li><a href="{:url('edit',['cate_id'=>$vo['cate_id']])}">编辑</a></li>
                                <li class="divider"></li>
                                <li><a href="javascript:;" onclick="del({$vo['cate_id']})">删除</a></li>
                            </ul>
                        </div>
                    </td>
                </tr>
                {/foreach}
                </tbody>
            </table>
        </div>
    </div>
</form>
<!-- 删除提示模态框 start -->
<div class="modal fade" id="del-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">栏目删除</h4>
            </div>
            <div class="modal-body">确定删除该栏目？</div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary change-confirm" data-dismiss="modal">确认</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<!-- 删除提示模态框 end -->
<div class="pagination pagination-sm pull-right">
</div>
<script>

    function del(cate_id) {
        $("#del-modal").modal();
        $("#del-modal .change-confirm").on("click",function() {
            location.href = "{:url('del')}"+'?cate_id='+cate_id;
        })
    }
</script>
{/block}